package engine

import (
	"fmt"
	"gateway/core"
)

type engineRuntime struct {
	connectorsRuntime map[string]connectorRuntime
	routesRuntime     map[string][]routeRuntime
	inboundsRuntime   map[string]inboundRuntime
	outboundsRuntime  map[string]outboundRuntime
	connectorChains   map[string]core.Chain
}

func newEngineRuntime() *engineRuntime {
	return &engineRuntime{
		connectorsRuntime: make(map[string]connectorRuntime),
		routesRuntime:     make(map[string][]routeRuntime),
		inboundsRuntime:   make(map[string]inboundRuntime),
		outboundsRuntime:  make(map[string]outboundRuntime),
		connectorChains:   make(map[string]core.Chain),
	}
}

func newRouteRuntime() *routeRuntime {
	return &routeRuntime{
		handlersRuntime: make([]handlerRuntime, 0),
	}
}

type routeRuntime struct {
	id              string
	inboundRuntime  inboundRuntime
	handlersRuntime []handlerRuntime
	outboundRuntime outboundRuntime
	routeChain      core.Chain
}

func (this *routeRuntime) String() string {
	return fmt.Sprintf("Route[%s]", this.id)
}

type connectorRuntime struct {
	id        string
	connector core.Connector
}

func (this *connectorRuntime) String() string {
	return fmt.Sprintf("Connector[%s]", this.id)
}

type inboundRuntime struct {
	id      string
	inbound core.Inbound
}

func (this *inboundRuntime) String() string {
	return fmt.Sprintf("Inbound[%s]", this.id)
}

type outboundRuntime struct {
	id       string
	outbound core.Outbound
}

func (this *outboundRuntime) String() string {
	return fmt.Sprintf("Outbound[%s]", this.id)
}

type handlerRuntime struct {
	id      string
	handler core.Handler
}

func (this *handlerRuntime) String() string {
	return fmt.Sprintf("Handler[%s]", this.id)
}
